import { reqSearchList } from "@/api";

const state = {
  searchList: {},
};
const mutations = {
  SET_SEARCHLIST_STATE(state, payload) {
    state.searchList = payload;
  },
};

const actions = {
  async getSearchList({ commit }, searchParams) {
    const res = await reqSearchList(searchParams);
    commit("SET_SEARCHLIST_STATE", res);
  },
};

const getters = {
  // 品牌列表
  trademarkList(state) {
    return state.searchList.trademarkList;
  },
  // 商品属性列表
  attrsList(state) {
    return state.searchList.attrsList;
  },
  // 商品列表
  goodsList(state) {
    return state.searchList.goodsList;
  },
  // 总页数页面
  totalPages(state) {
    return state.searchList.totalPages;
  },
  total(state){
    return state.searchList.total
  }
};

export default {
  namespaced: true,
  state,
  mutations,
  actions,
  getters,
};
